package com.timi_licai.timi_licai_account.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.timi_licai.timi_licai_account.R;
import com.timi_licai.timi_licai_account.listener.CameraDialogInterface;
import com.timi_licai.timi_licai_account.listener.CategoryCustomInterface;

/**
 * 点击添加信息页面的相机图标 弹出的dialog
 */
public class CategoryCustomDialog extends Dialog implements View.OnClickListener {
    private CategoryCustomInterface categoryCustomInterface;
    private EditText editDialogEdit;
    private ImageView imgDialogIcon;

    public CategoryCustomDialog(Context context, int theme,
                                CategoryCustomInterface categoryCustomInterface) {
        super(context, theme);
        this.categoryCustomInterface = categoryCustomInterface;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_add_category_custom);
        TextView txtDialogCancel = (TextView) findViewById(R.id.dialog_category_custom_cancel);
        TextView txtDialogEnsure = (TextView) findViewById(R.id.dialog_category_custom_ensure);
        imgDialogIcon = (ImageView) findViewById(R.id.dialog_category_custom_image);
        editDialogEdit = (EditText) findViewById(R.id.dialog_category_custom_edit);
        txtDialogCancel.setOnClickListener(this);
        txtDialogEnsure.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (categoryCustomInterface != null) {
            int id = v.getId();
            switch (id) {
                case R.id.dialog_category_custom_cancel:
                    categoryCustomInterface.getCategoryCustomDialogClick(id);
                    break;
                case R.id.dialog_category_custom_ensure:
                    String inputString = editDialogEdit.getText().toString().trim();

                    categoryCustomInterface.getCategoryCustomDialogEdit(inputString);
                    categoryCustomInterface.getCategoryCustomDialogClick(id);
                    break;
            }
        }
    }
}
